#pragma once

#include<windows.h>
#include<tchar.h>
#include "Coordinator2D.h"
#include "ThreadedComport.h"

#define WV_RECEIVE (WM_USER + 3)

class WaveViewer;

BYTE registerWaveViewerClass(HINSTANCE);
LRESULT CALLBACK waveViewerProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
HWND createWaveWindow(HWND parent, HINSTANCE);
WaveViewer* getWaveViewerObjectFromWindow(HWND hwnd);

class WaveViewer
{
	private:
		void releaseBufferDC();

	public:
		static TCHAR szClassName[];
		HWND hwnd;
		COLORREF bgColor, color;
		HFONT hFont;
		Coordinator2D coord;
		HDC memoryDC;
		HBITMAP hbmpBuffer, oldBmp;
		HBRUSH bgbrush, oldBrush;
		HPEN hPen, oldPen;
		ThreadedComport comThread;

		int x, y, xp, yp; //current position of the wave

	public:
		WaveViewer(void);
		WaveViewer(HWND);
		~WaveViewer(void);

		void onSizeChanged(HWND hwnd, WPARAM wparam, LPARAM lparam);
		void paint(HWND);

		void setXY(int _y);

};

